import 'dart:convert';

import 'package:example_example/services/ScreenAdapter.dart';
import 'package:example_example/services/TLSizeFit.dart';
import 'package:flutter/material.dart';
import '../../util/LogUtil.dart';

import '../../YColors.dart';
import '../view/ExpandedText.dart';

//import '../pages/YColors.dart';
//import '../bean/order/MarketBean.dart';

Widget ItemFinishTaskView(bean) {
  // TODO: implement build
  return Container(
    width: double.infinity,
//    margin: EdgeInsets.fromLTRB(20, 20, 20, 0),
//    padding: EdgeInsets.fromLTRB(20, 0, 10, 20),
    margin: EdgeInsets.fromLTRB(
        TLSizeFit.setPx(20), TLSizeFit.setPx(20), TLSizeFit.setPx(20), 0),
    padding: EdgeInsets.fromLTRB(TLSizeFit.setPx(20), TLSizeFit.setPx(4),
        TLSizeFit.setPx(20), TLSizeFit.setPx(20)),

    child: Column(
      children: <Widget>[
        SizedBox(
          height: TLSizeFit.setPx(10),
        ),
        Row(
          children: <Widget>[
//            Text(
//              "流程名称",
//              style: TextStyle(
//                fontSize: 14.0,
//                color: YColors.a,
//              ),
//            ),
//            SizedBox(
//              width: 30,
//            ),
            Text(
              bean["name"] != null ? bean["name"] : "",
              style: TextStyle(
                fontSize: ScreenAdapter.size(34),
                color: YColors.a,
              ),
            ),
          ],
        ),
        SizedBox(
          height: TLSizeFit.setPx(10),
        ),
        Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Text(
              "任务名称:",
              style: TextStyle(
                fontSize: ScreenAdapter.size(28),
                color: YColors.a,
              ),
            ),
            SizedBox(
              width: TLSizeFit.setPx(8),
            ),
            ExpandedText(
              bean["processDefinitionName"] != null
                  ? bean["processDefinitionName"]
                  : "",
            ),

//            Expanded(child: Text(
//              "流程的卡肯德基流程的卡肯德基流程的卡肯德基流程的卡肯德基流程的卡肯德基流程的卡肯德基流程的卡肯德基流程的卡肯德基流程的卡肯德基流程的卡肯德基流程的卡肯德基流程的卡肯德基",
////              bean["processDefinitionName"] != null
////                  ? bean["processDefinitionName"]
////                  : "",
//              style: TextStyle(
//                fontSize: ScreenAdapter.size(28),
//                color: YColors.a,
//              ),
//              overflow: TextOverflow.ellipsis,
//              maxLines: 2,
//            ),),
          ],
        ),
        SizedBox(
          height: TLSizeFit.setPx(10),
        ),
        Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Text(
              "标题:",
              style: TextStyle(
                fontSize: ScreenAdapter.size(28),
                color: YColors.a,
              ),
            ),
            SizedBox(
              width: TLSizeFit.setPx(8),
            ),
            ExpandedText(
              getDataTitle(bean),
            ),
//            Text(
////              "我的标题",
////            bean["ppProjectName"],
//              getDataTitle(bean),
//              style: TextStyle(
//                fontSize: ScreenAdapter.size(28),
//                color: YColors.a,
//              ),
//            ),
          ],
        ),
        SizedBox(
          height: TLSizeFit.setPx(10),
        ),
        Row(
          children: <Widget>[
            Text(
              "状态:",
              style: TextStyle(
                fontSize: ScreenAdapter.size(28),
                color: YColors.a,
              ),
            ),
            SizedBox(
              width: TLSizeFit.setPx(8),
            ),
            Text(
//              "状态。。。。。",
              getDataStatusText(bean),
              style: TextStyle(
                fontSize: ScreenAdapter.size(28),
                color: YColors.a,
              ),
            ),
          ],
        ),
        SizedBox(
          height: TLSizeFit.setPx(10),
        ),
        Row(
          children: <Widget>[
            Text(
              "开始时间:",
              style: TextStyle(
                fontSize: ScreenAdapter.size(28),
                color: YColors.a,
              ),
            ),
            SizedBox(
              width: TLSizeFit.setPx(8),
            ),
            Text(
//              "状态。。。。。",
              bean["createTime"] != null ? bean["createTime"] : "",
              style: TextStyle(
                fontSize: ScreenAdapter.size(28),
                color: YColors.a,
              ),
            ),
          ],
        ),
        SizedBox(
          height: TLSizeFit.setPx(10),
        ),
        Row(
          children: <Widget>[
            Text(
              "结束时间:",
              style: TextStyle(
                fontSize: ScreenAdapter.size(28),
                color: YColors.a,
              ),
            ),
            SizedBox(
              width: TLSizeFit.setPx(8),
            ),
            Text(
//              "状态。。。。。",
              bean["lastUpdateTime"] != null ? bean["lastUpdateTime"] : "",
              style: TextStyle(
                fontSize: ScreenAdapter.size(28),
                color: YColors.a,
              ),
            ),
          ],
        ),
      ],
    ),
    decoration: BoxDecoration(
        // 边框 zj
        color: Colors.white, // 背景色 zj
//        border: Border.all(
//            // 边框 zj
//            color: Colors.black12, // 边框颜色 zj
//            width: 1.0 // 边框宽度 zj
//
//            ),
        borderRadius: BorderRadius.all(// 圆角
            //  Radius.circular(150),    //圆形
            Radius.circular(6) // 圆角 zj
            ),
        boxShadow: [
          BoxShadow(
//                            color: Colors.black12,
//              color: Color(0x554CBC5A), // 55  是透明度
              color: Color(0x12000000), // 55  是透明度
              offset: Offset(0.0, 2.0), //阴影xy轴偏移量
              blurRadius: 4.0, //阴影模糊程度
              spreadRadius: 1 //阴影扩散程度
              )
        ]

//            // 设置单圆角：左上角的圆角为5，右上角的圆角为10
//            borderRadius: BorderRadius.only(
//                    topLeft: Radius.circular(5),
//                   topRight: Radius.circular(10),
//              ),

        ),
  );
}

/**
 * 标题
 */
String getDataTitle(bean) {
  var variableJson = bean['variableJson'];
//  LogUtil.v("variableJson:$variableJson");
  variableJson = json.decode(variableJson);
  var ppProjectName = variableJson["title"]; //ppProjectName
  LogUtil.v("ppProjectName:$ppProjectName");
  if (ppProjectName == null) {
    ppProjectName = "";
  }
  return ppProjectName;
}

/**
 * 状态
 */
String getDataStatusText(bean) {
  var variableJson = bean['variableJson'];
//  LogUtil.v("variableJson:$variableJson");
  variableJson = json.decode(variableJson);
  var statusText = variableJson["statusText"];
//  LogUtil.v("statusText:$statusText");
  if (statusText == null) {
    statusText = "";
  }
  return statusText;
}
